package com.xca.touchdemo;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

import com.xca.touchdemo.base.BaseActivity;
import com.xca.touchdemo.view.SignatureView;

public class SignatureActivity extends BaseActivity implements View.OnClickListener {
    private Button mClear , mSave ;
    private SignatureView mSignView ;
    @Override
    public int getLayoutId() {
        return R.layout.activity_signature;
    }

    @Override
    public void init() {
        mClear = findViewById(R.id.clear);
        mSave = findViewById(R.id.save) ;
        mSignView = findViewById(R.id.sign_view) ;
        mClear.setOnClickListener(this);
        mSave.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        if (isFastClick()){
            showToast("请勿连续快速点击");
            return;
        }
        int id = v.getId() ;
        if (id == R.id.clear){
            mSignView.clear();
        } else if (id == R.id.save) {
            mSignView.save();
            mSignView.saveImageToGallery();
        }
    }
}